package top.lshaci.learning.jvm.string;

import java.io.FileWriter;

/**
 * StringGenerate
 *
 * @author lshaci
 * @date 2020/7/15 17:41
 * @since 1.0.0
 */
public class StringGenerate {

    public static void main(String[] args) throws Exception {
        FileWriter fw = new FileWriter("words.txt");

        for (int i = 0; i < 100000; i++) {
            // 1 - 10
            int len = (int) (Math.random() * 10) + 1;
            fw.write(getString(len) + "\n");
        }

        fw.close();
    }

    private static String getString(int len) {
        String str = "";
        for (int i = 0; i < len; i++) {
            // 65 - 90, 97 - 122
            int num = (int) (Math.random() * (90 - 65 + 1)) + 65 + (int) (Math.random() * 2) * 32;
            str += (char) num;
        }
        return str;
    }
}
